package cn.bugDance.domain.task.service;

import cn.bugDance.domain.award.model.entity.TaskEntity;
import cn.bugDance.domain.task.repository.ITaskRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Service
@Slf4j
public class TaskService implements ITaskService{

    @Resource
    private ITaskRepository taskRepository;


    @Override
    public List<TaskEntity> queryNoCompletedTask() {
        return taskRepository.queryNoCompletedTask();
    }

    @Override
    public void sendAward(TaskEntity taskEntity) {
        taskRepository.sendAward(taskEntity);
    }

    @Override
    public void updateTaskStateSuccess(TaskEntity taskEntity) {
        String messageId = taskEntity.getMessage().getId();
        taskRepository.updateTaskStateSuccess(messageId);
    }

    @Override
    public void updateTaskStateFail(TaskEntity taskEntity) {
        String messageId = taskEntity.getMessage().getId();
        taskRepository.updateTaskStateFail(messageId);
    }
}
